package viettravel.guiandevent.map;

import java.util.ArrayList;

import viettravel.DAO.LocalMapDAO;
import viettravel.guiandevent.R;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListMoveMapAdapter extends BaseAdapter {

	private ArrayList<LocalMapDAO> mListLocal;
	private Context mContext;

	public ListMoveMapAdapter(Context _context, ArrayList<LocalMapDAO> _rowPlace) {
		mListLocal = new ArrayList<LocalMapDAO>();
		mListLocal.addAll(_rowPlace);
		mContext = _context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListLocal.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mListLocal.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View _view, ViewGroup _viewGroup) {
		// TODO Auto-generated method stub
		View view = _view;
		if (view == null) {
			LayoutInflater layoutInflater = (LayoutInflater) mContext
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = layoutInflater.inflate(R.layout.row_local_map, null);
		}

		LocalMapDAO l = mListLocal.get(position);
		Typeface tf1 = Typeface.createFromAsset(mContext.getAssets(),
				"fonts/utm_caviar.ttf");
		Typeface tf2 = Typeface.createFromAsset(mContext.getAssets(),
				"fonts/utm_nyala.ttf");
		ImageView rowLocalImage = (ImageView) view
				.findViewById(R.id.rowLocalImage);
		TextView rowLocalName = (TextView) view.findViewById(R.id.rowLocalName);
		TextView rowLocalAddress = (TextView) view
				.findViewById(R.id.rowLocalAddress);

		rowLocalImage.setBackgroundDrawable(l.getDrawable());

		rowLocalName.setTypeface(tf1);
		rowLocalName.setText(l.getName());

		rowLocalAddress.setTypeface(tf2);
		rowLocalAddress.setText(l.getAddress());
		return view;
	}
}
